package com.xce.order.controller;

import com.xce.order.entity.OrderTbl;
import com.xce.order.service.OrderTblService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@Slf4j
@Tag(name = "接口")
@RestController
public class OrderTblController {

    @Autowired
    private OrderTblService orderService;

    @Operation(summary = "创建订单")
    @GetMapping("/create")
    public String create(@RequestParam("userId") String userId,
                         @RequestParam("commodityCode") String commodityCode,
                         @RequestParam("count") Integer count) {

        OrderTbl orderTbl = orderService.create(userId, commodityCode, count);
        return "order create success = 订单id： 【" + orderTbl.getId() + "】";
    }

}
